home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / rpm / rpmcli.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-22  |  25.5 KB  |  809 lines

  1. #ifndef H_RPMCLI
  2. #define    H_RPMCLI
  3.  
  4. /** \ingroup rpmcli rpmbuild
  5.  * \file lib/rpmcli.h
  6.  */
  7.  
  8. #include "rpmlib.h"
  9. #include "rpmurl.h"
  10. #include "rpmmacro.h"
  11. #include "argv.h"
  12.  
  13. /** \ingroup rpmcli
  14.  * Should version 3 packages be produced?
  15.  */
  16. /*@-redecl@*/
  17. /*@unchecked@*/
  18. extern int _noDirTokens;
  19. /*@=redecl@*/
  20.  
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. /** \ingroup rpmcli
  26.  * Popt option table for options shared by all modes and executables.
  27.  */
  28. /*@unchecked@*/
  29. extern struct poptOption        rpmcliAllPoptTable[];
  30.  
  31. /*@unchecked@*/
  32. extern int ftsOpts;
  33.  
  34. /*@unchecked@*/
  35. extern struct poptOption        rpmcliFtsPoptTable[];
  36.  
  37. /*@unchecked@*/ /*@observer@*/ /*@null@*/
  38. extern const char * rpmcliPipeOutput;
  39.  
  40. /*@unchecked@*/ /*@observer@*/ /*@null@*/
  41. extern const char * rpmcliRcfile;
  42.  
  43. /*@unchecked@*/ /*@observer@*/ /*@null@*/
  44. extern const char * rpmcliRootDir;
  45.  
  46. /**
  47.  * Initialize most everything needed by an rpm CLI executable context.
  48.  * @param argc            no. of args
  49.  * @param argv            arg array
  50.  * @param optionsTable        popt option table
  51.  * @return            popt context (or NULL)
  52.  */
  53. /*@null@*/
  54. poptContext
  55. rpmcliInit(int argc, char *const argv[], struct poptOption * optionsTable)
  56.     /*@globals rpmCLIMacroContext, rpmGlobalMacroContext, h_errno, stderr, 
  57.         fileSystem, internalState @*/
  58.     /*@modifies rpmCLIMacroContext, rpmGlobalMacroContext, stderr, 
  59.         fileSystem, internalState @*/;
  60.  
  61. /**
  62.  * Make sure that rpm configuration has been read.
  63.  * @warning Options like --rcfile and --verbose must precede callers option.
  64.  */
  65. /*@mayexit@*/
  66. void rpmcliConfigured(void)
  67.     /*@globals rpmCLIMacroContext, rpmGlobalMacroContext, h_errno,
  68.         fileSystem, internalState @*/
  69.     /*@modifies rpmCLIMacroContext, rpmGlobalMacroContext,
  70.         fileSystem, internalState @*/;
  71.  
  72. /**
  73.  * Destroy most everything needed by an rpm CLI executable context.
  74.  * @param optCon        popt context
  75.  * @return            NULL always
  76.  */
  77. poptContext
  78. rpmcliFini(/*@only@*/ /*@null@*/ poptContext optCon)
  79.     /*@modifies optCon @*/;
  80.  
  81. /**
  82.  * Common/global popt tokens used for command line option tables.
  83.  */
  84. #define    RPMCLI_POPT_NODEPS        -1025
  85. #define    RPMCLI_POPT_FORCE        -1026
  86. #define    RPMCLI_POPT_NOMD5        -1027
  87. #define    RPMCLI_POPT_NOSCRIPTS        -1028
  88. #define    RPMCLI_POPT_NOSIGNATURE        -1029
  89. #define    RPMCLI_POPT_NODIGEST        -1030
  90. #define    RPMCLI_POPT_NOHDRCHK        -1031
  91. #define    RPMCLI_POPT_NOCONTEXTS        -1032
  92.  
  93. /* ==================================================================== */
  94. /** \name RPMQV */
  95. /*@{*/
  96.  
  97. /** \ingroup rpmcli
  98.  * Query/Verify argument qualifiers.
  99.  * @todo Reassign to tag values.
  100.  */
  101. typedef enum rpmQVSources_e {
  102.     RPMQV_PACKAGE = 0,    /*!< ... from package name db search. */
  103.     RPMQV_PATH,        /*!< ... from file path db search. */
  104.     RPMQV_ALL,        /*!< ... from each installed package. */
  105.     RPMQV_RPM,         /*!< ... from reading binary rpm package. */
  106.     RPMQV_GROUP,    /*!< ... from group db search. */
  107.     RPMQV_WHATPROVIDES,    /*!< ... from provides db search. */
  108.     RPMQV_WHATREQUIRES,    /*!< ... from requires db search. */
  109.     RPMQV_TRIGGEREDBY,    /*!< ... from trigger db search. */
  110.     RPMQV_DBOFFSET,    /*!< ... from database header instance. */
  111.     RPMQV_SPECFILE,    /*!< ... from spec file parse (query only). */
  112.     RPMQV_PKGID,    /*!< ... from package id (header+payload MD5). */
  113.     RPMQV_HDRID,    /*!< ... from header id (immutable header SHA1). */
  114.     RPMQV_FILEID,    /*!< ... from file id (file MD5). */
  115.     RPMQV_TID,        /*!< ... from install transaction id (time stamp). */
  116.     RPMQV_HDLIST,    /*!< ... from system hdlist. */
  117.     RPMQV_FTSWALK    /*!< ... from fts(3) walk. */
  118. } rpmQVSources;
  119.  
  120. /** \ingroup rpmcli
  121.  * Bit(s) for rpmVerifyFile() attributes and result.
  122.  */
  123. typedef enum rpmVerifyAttrs_e {
  124.     RPMVERIFY_NONE    = 0,        /*!< */
  125.     RPMVERIFY_MD5    = (1 << 0),    /*!< from %verify(md5) */
  126.     RPMVERIFY_FILESIZE    = (1 << 1),    /*!< from %verify(size) */
  127.     RPMVERIFY_LINKTO    = (1 << 2),    /*!< from %verify(link) */
  128.     RPMVERIFY_USER    = (1 << 3),    /*!< from %verify(user) */
  129.     RPMVERIFY_GROUP    = (1 << 4),    /*!< from %verify(group) */
  130.     RPMVERIFY_MTIME    = (1 << 5),    /*!< from %verify(mtime) */
  131.     RPMVERIFY_MODE    = (1 << 6),    /*!< from %verify(mode) */
  132.     RPMVERIFY_RDEV    = (1 << 7),    /*!< from %verify(rdev) */
  133.     /* bits 8-14 unused, reserved for rpmVerifyAttrs */
  134.     RPMVERIFY_CONTEXTS    = (1 << 15),    /*!< verify: from --nocontexts */
  135.     /* bits 16-22 used in rpmVerifyFlags */
  136.     /* bits 23-27 used in rpmQueryFlags */
  137.     RPMVERIFY_READLINKFAIL= (1 << 28),    /*!< readlink failed */
  138.     RPMVERIFY_READFAIL    = (1 << 29),    /*!< file read failed */
  139.     RPMVERIFY_LSTATFAIL    = (1 << 30),    /*!< lstat failed */
  140.     RPMVERIFY_LGETFILECONFAIL    = (1 << 31)    /*!< lgetfilecon failed */
  141. } rpmVerifyAttrs;
  142. #define    RPMVERIFY_ALL        ~(RPMVERIFY_NONE)
  143. #define    RPMVERIFY_FAILURES    \
  144.   (RPMVERIFY_LSTATFAIL|RPMVERIFY_READFAIL|RPMVERIFY_READLINKFAIL|RPMVERIFY_LGETFILECONFAIL)
  145.  
  146. /** \ingroup rpmcli
  147.  * Bit(s) to control rpmQuery() operation, stored in qva_flags.
  148.  * @todo Merge rpmQueryFlags, rpmVerifyFlags, and rpmVerifyAttrs?.
  149.  */
  150. typedef enum rpmQueryFlags_e {
  151. /*@-enummemuse@*/
  152.     QUERY_FOR_DEFAULT    = 0,        /*!< */
  153.     QUERY_MD5        = (1 << 0),    /*!< from --nomd5 */
  154.     QUERY_SIZE        = (1 << 1),    /*!< from --nosize */
  155.     QUERY_LINKTO    = (1 << 2),    /*!< from --nolink */
  156.     QUERY_USER        = (1 << 3),    /*!< from --nouser) */
  157.     QUERY_GROUP        = (1 << 4),    /*!< from --nogroup) */
  158.     QUERY_MTIME        = (1 << 5),    /*!< from --nomtime) */
  159.     QUERY_MODE        = (1 << 6),    /*!< from --nomode) */
  160.     QUERY_RDEV        = (1 << 7),    /*!< from --nodev */
  161.     /* bits 8-14 unused, reserved for rpmVerifyAttrs */
  162.     QUERY_CONTEXTS    = (1 << 15),    /*!< verify: from --nocontexts */
  163.     QUERY_FILES        = (1 << 16),    /*!< verify: from --nofiles */
  164.     QUERY_DEPS        = (1 << 17),    /*!< verify: from --nodeps */
  165.     QUERY_SCRIPT    = (1 << 18),    /*!< verify: from --noscripts */
  166.     QUERY_DIGEST    = (1 << 19),    /*!< verify: from --nodigest */
  167.     QUERY_SIGNATURE    = (1 << 20),    /*!< verify: from --nosignature */
  168.     QUERY_PATCHES    = (1 << 21),    /*!< verify: from --nopatches */
  169.     QUERY_HDRCHK    = (1 << 22),    /*!< verify: from --nohdrchk */
  170. /*@=enummemuse@*/
  171.     QUERY_FOR_LIST    = (1 << 23),    /*!< query:  from --list */
  172.     QUERY_FOR_STATE    = (1 << 24),    /*!< query:  from --state */
  173.     QUERY_FOR_DOCS    = (1 << 25),    /*!< query:  from --docfiles */
  174.     QUERY_FOR_CONFIG    = (1 << 26),    /*!< query:  from --configfiles */
  175.     QUERY_FOR_DUMPFILES    = (1 << 27)    /*!< query:  from --dump */
  176. } rpmQueryFlags;
  177.  
  178. #define    _QUERY_FOR_BITS    \
  179.    (QUERY_FOR_LIST|QUERY_FOR_STATE|QUERY_FOR_DOCS|QUERY_FOR_CONFIG|\
  180.     QUERY_FOR_DUMPFILES)
  181.  
  182. /** \ingroup rpmcli
  183.  * Bit(s) from common command line options.
  184.  */
  185. /*@unchecked@*/
  186. extern rpmQueryFlags rpmcliQueryFlags;
  187.  
  188. /** \ingroup rpmcli
  189.  * Bit(s) to control rpmVerify() operation, stored in qva_flags.
  190.  * @todo Merge rpmQueryFlags, rpmVerifyFlags, and rpmVerifyAttrs values?.
  191.  */
  192. typedef enum rpmVerifyFlags_e {
  193. /*@-enummemuse@*/
  194.     VERIFY_DEFAULT    = 0,        /*!< */
  195. /*@=enummemuse@*/
  196.     VERIFY_MD5        = (1 << 0),    /*!< from --nomd5 */
  197.     VERIFY_SIZE        = (1 << 1),    /*!< from --nosize */
  198.     VERIFY_LINKTO    = (1 << 2),    /*!< from --nolinkto */
  199.     VERIFY_USER        = (1 << 3),    /*!< from --nouser */
  200.     VERIFY_GROUP    = (1 << 4),    /*!< from --nogroup */
  201.     VERIFY_MTIME    = (1 << 5),    /*!< from --nomtime */
  202.     VERIFY_MODE        = (1 << 6),    /*!< from --nomode */
  203.     VERIFY_RDEV        = (1 << 7),    /*!< from --nodev */
  204.     /* bits 8-14 unused, reserved for rpmVerifyAttrs */
  205.     VERIFY_CONTEXTS    = (1 << 15),    /*!< verify: from --nocontexts */
  206.     VERIFY_FILES    = (1 << 16),    /*!< verify: from --nofiles */
  207.     VERIFY_DEPS        = (1 << 17),    /*!< verify: from --nodeps */
  208.     VERIFY_SCRIPT    = (1 << 18),    /*!< verify: from --noscripts */
  209.     VERIFY_DIGEST    = (1 << 19),    /*!< verify: from --nodigest */
  210.     VERIFY_SIGNATURE    = (1 << 20),    /*!< verify: from --nosignature */
  211.     VERIFY_PATCHES    = (1 << 21),    /*!< verify: from --nopatches */
  212.     VERIFY_HDRCHK    = (1 << 22),    /*!< verify: from --nohdrchk */
  213. /*@-enummemuse@*/
  214.     VERIFY_FOR_LIST    = (1 << 23),    /*!< query:  from --list */
  215.     VERIFY_FOR_STATE    = (1 << 24),    /*!< query:  from --state */
  216.     VERIFY_FOR_DOCS    = (1 << 25),    /*!< query:  from --docfiles */
  217.     VERIFY_FOR_CONFIG    = (1 << 26),    /*!< query:  from --configfiles */
  218.     VERIFY_FOR_DUMPFILES= (1 << 27)    /*!< query:  from --dump */
  219. /*@=enummemuse@*/
  220.     /* bits 28-31 used in rpmVerifyAttrs */
  221. } rpmVerifyFlags;
  222.  
  223. #define    VERIFY_ATTRS    \
  224.   ( VERIFY_MD5 | VERIFY_SIZE | VERIFY_LINKTO | VERIFY_USER | VERIFY_GROUP | \
  225.     VERIFY_MTIME | VERIFY_MODE | VERIFY_RDEV | VERIFY_CONTEXTS )
  226. #define    VERIFY_ALL    \
  227.   ( VERIFY_ATTRS | VERIFY_FILES | VERIFY_DEPS | VERIFY_SCRIPT | VERIFY_DIGEST |\
  228.     VERIFY_SIGNATURE | VERIFY_HDRCHK )
  229.  
  230. /** \ingroup rpmcli
  231.  */
  232. typedef struct rpmQVKArguments_s * QVA_t;
  233.  
  234. /** \ingroup rpmcli
  235.  * Function to display iterator matches.
  236.  *
  237.  * @param qva        parsed query/verify options
  238.  * @param ts        transaction set
  239.  * @param h        header to use for query/verify
  240.  * @return        0 on success
  241.  */
  242. typedef    int (*QVF_t) (QVA_t qva, rpmts ts, Header h)
  243.     /*@globals fileSystem @*/
  244.     /*@modifies qva, ts, fileSystem @*/;
  245.  
  246. /** \ingroup rpmcli
  247.  * Function to query spec file.
  248.  *
  249.  * @param ts        transaction set
  250.  * @param qva        parsed query/verify options
  251.  * @param arg        query argument
  252.  * @return        0 on success
  253.  */
  254. typedef    int (*QSpecF_t) (rpmts ts, QVA_t qva, const char * arg)
  255.     /*@globals rpmGlobalMacroContext, h_errno,
  256.         fileSystem, internalState @*/
  257.     /*@modifies ts, qva, rpmGlobalMacroContext,
  258.         fileSystem, internalState @*/;
  259.  
  260. /** \ingroup rpmcli
  261.  * Describe query/verify/signature command line operation.
  262.  */
  263. struct rpmQVKArguments_s {
  264.     rpmQVSources qva_source;    /*!< Identify CLI arg type. */
  265.     int     qva_sourceCount;/*!< Exclusive option check (>1 is error). */
  266.     rpmQueryFlags qva_flags;    /*!< Bit(s) to control operation. */
  267.     rpmfileAttrs qva_fflags;    /*!< Bit(s) to filter on attribute. */
  268. /*@only@*/ /*@null@*/
  269.     rpmdbMatchIterator qva_mi;    /*!< Match iterator on selected headers. */
  270. /*@refccounted@*/ /*@relnull@*/
  271.     rpmgi qva_gi;        /*!< Generalized iterator on args. */
  272.     rpmRC qva_rc;        /*!< Current return code. */
  273.  
  274. /*@null@*/
  275.     QVF_t qva_showPackage;    /*!< Function to display iterator matches. */
  276. /*@null@*/
  277.     QSpecF_t qva_specQuery;    /*!< Function to query spec file. */
  278. /*@unused@*/
  279.     int qva_verbose;        /*!< (unused) */
  280. /*@only@*/ /*@null@*/
  281.     const char * qva_queryFormat;/*!< Format for headerSprintf(). */
  282.     int sign;            /*!< Is a passphrase needed? */
  283. /*@observer@*/
  284.     const char * passPhrase;    /*!< Pass phrase. */
  285. /*@observer@*/ /*@null@*/
  286.     const char * qva_prefix;    /*!< Path to top of install tree. */
  287.     char    qva_mode;
  288.         /*!<
  289.         - 'q'    from --query, -q
  290.         - 'Q'    from --querytags
  291.         - 'V'    from --verify, -V
  292.         - 'A'    from --addsign
  293.         - 'I'    from --import
  294.         - 'K'    from --checksig, -K
  295.         - 'R'    from --resign
  296.         */
  297.     char    qva_char;    /*!< (unused) always ' ' */
  298. };
  299.  
  300. /** \ingroup rpmcli
  301.  */
  302. /*@unchecked@*/
  303. extern struct rpmQVKArguments_s rpmQVKArgs;
  304.  
  305. /** \ingroup rpmcli
  306.  */
  307. /*@unchecked@*/
  308. extern struct poptOption rpmQVSourcePoptTable[];
  309.  
  310. /** \ingroup rpmcli
  311.  */
  312. /*@unchecked@*/
  313. extern int specedit;
  314.  
  315. /** \ingroup rpmcli
  316.  */
  317. /*@unchecked@*/
  318. extern struct poptOption rpmQueryPoptTable[];
  319.  
  320. /** \ingroup rpmcli
  321.  */
  322. /*@unchecked@*/
  323. extern struct poptOption rpmVerifyPoptTable[];
  324.  
  325. /** \ingroup rpmcli
  326.  * Display query/verify information for each header in iterator.
  327.  *
  328.  * This routine uses:
  329.  *    - qva->qva_mi        rpm database iterator
  330.  *    - qva->qva_showPackage    query/verify display routine
  331.  *
  332.  * @param qva        parsed query/verify options
  333.  * @param ts        transaction set
  334.  * @return        result of last non-zero showPackage() return
  335.  */
  336. int rpmcliShowMatches(QVA_t qva, rpmts ts)
  337.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  338.     /*@modifies qva, rpmGlobalMacroContext, fileSystem, internalState @*/;
  339.  
  340. /** \ingroup rpmcli
  341.  * Display list of tags that can be used in --queryformat.
  342.  * @param fp    file handle to use for display
  343.  */
  344. void rpmDisplayQueryTags(FILE * fp)
  345.     /*@globals fileSystem @*/
  346.     /*@modifies *fp, fileSystem @*/;
  347.  
  348. /** \ingroup rpmcli
  349.  * Common query/verify source interface, called once for each CLI arg.
  350.  *
  351.  * This routine uses:
  352.  *    - qva->qva_mi        rpm database iterator
  353.  *    - qva->qva_showPackage    query/verify display routine
  354.  *
  355.  * @param qva        parsed query/verify options
  356.  * @param ts        transaction set
  357.  * @param arg        name of source to query/verify
  358.  * @return        showPackage() result, 1 if rpmdbInitIterator() is NULL
  359.  */
  360. int rpmQueryVerify(QVA_t qva, rpmts ts, const char * arg)
  361.     /*@globals rpmGlobalMacroContext, h_errno,
  362.         fileSystem, internalState @*/
  363.     /*@modifies qva, ts, rpmGlobalMacroContext,
  364.         fileSystem, internalState @*/;
  365.  
  366. /** \ingroup rpmcli
  367.  * Display results of package query.
  368.  * @todo Devise a meaningful return code.
  369.  * @param qva        parsed query/verify options
  370.  * @param ts        transaction set
  371.  * @param h        header to use for query
  372.  * @return        0 always
  373.  */
  374. int showQueryPackage(QVA_t qva, rpmts ts, Header h)
  375.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  376.     /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
  377.  
  378. /** \ingroup rpmcli
  379.  * Iterate over query/verify arg list.
  380.  * @param ts        transaction set
  381.  * @param qva        parsed query/verify options
  382.  * @param argv        query argument(s) (or NULL)
  383.  * @return        0 on success, else no. of failures
  384.  */
  385. int rpmcliArgIter(rpmts ts, QVA_t qva, /*@null@*/ ARGV_t argv)
  386.     /*@globals ftsOpts, rpmGlobalMacroContext, h_errno,
  387.         fileSystem, internalState @*/
  388.     /*@modifies ts, qva, ftsOpts, rpmGlobalMacroContext,
  389.         fileSystem, internalState @*/;
  390.  
  391. /** \ingroup rpmcli
  392.  * Display package information.
  393.  * @todo hack: RPMQV_ALL can pass char ** arglist = NULL, not char * arg. Union?
  394.  * @param ts        transaction set
  395.  * @param qva        parsed query/verify options
  396.  * @param argv        query argument(s) (or NULL)
  397.  * @return        0 on success, else no. of failures
  398.  */
  399. int rpmcliQuery(rpmts ts, QVA_t qva, /*@null@*/ const char ** argv)
  400.     /*@globals rpmGlobalMacroContext, h_errno,
  401.         fileSystem, internalState @*/
  402.     /*@modifies ts, qva, rpmGlobalMacroContext,
  403.         fileSystem, internalState @*/;
  404.  
  405. /** \ingroup rpmcli
  406.  * Verify file attributes (including MD5 sum).
  407.  * @todo gnorpm and python bindings prevent this from being static.
  408.  * @param ts        transaction set
  409.  * @param fi        file info (with linked header and current file index)
  410.  * @retval *res        bit(s) returned to indicate failure
  411.  * @param omitMask    bit(s) to disable verify checks
  412.  * @return        0 on success (or not installed), 1 on error
  413.  */
  414. /*@-incondefs@*/
  415. int rpmVerifyFile(const rpmts ts, rpmfi fi,
  416.         /*@out@*/ rpmVerifyAttrs * res, rpmVerifyAttrs omitMask)
  417.     /*@globals h_errno, fileSystem, internalState @*/
  418.     /*@modifies ts, fi, *res, fileSystem, internalState @*/
  419.     /*@requires maxSet(res) >= 0 @*/;
  420. /*@=incondefs@*/
  421.  
  422. /** \ingroup rpmcli
  423.  * Display results of package verify.
  424.  * @param qva        parsed query/verify options
  425.  * @param ts        transaction set
  426.  * @param h        header to use for verify
  427.  * @return        result of last non-zero verify return
  428.  */
  429. int showVerifyPackage(QVA_t qva, rpmts ts, Header h)
  430.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  431.     /*@modifies ts, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
  432.  
  433. /**
  434.  * Check package and header signatures.
  435.  * @param qva        parsed query/verify options
  436.  * @param ts        transaction set
  437.  * @param fd        package file handle
  438.  * @param fn        package file name
  439.  * @return        0 on success, 1 on failure
  440.  */
  441. int rpmVerifySignatures(QVA_t qva, rpmts ts, FD_t fd, const char * fn)
  442.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  443.     /*@modifies qva, ts, fd, rpmGlobalMacroContext, h_errno,
  444.         fileSystem, internalState @*/;
  445.  
  446. /** \ingroup rpmcli
  447.  * Verify package install.
  448.  * @todo hack: RPMQV_ALL can pass char ** arglist = NULL, not char * arg. Union?
  449.  * @param ts        transaction set
  450.  * @param qva        parsed query/verify options
  451.  * @param argv        verify argument(s) (or NULL)
  452.  * @return        0 on success, else no. of failures
  453.  */
  454. int rpmcliVerify(rpmts ts, QVA_t qva, /*@null@*/ const char ** argv)
  455.     /*@globals rpmGlobalMacroContext, h_errno,
  456.         fileSystem, internalState @*/
  457.     /*@modifies ts, qva, rpmGlobalMacroContext,
  458.         fileSystem, internalState @*/;
  459.  
  460. /*@}*/
  461. /* ==================================================================== */
  462. /** \name RPMBT */
  463. /*@{*/
  464.  
  465. /** \ingroup rpmcli
  466.  * Describe build command line request.
  467.  */
  468. struct rpmBuildArguments_s {
  469.     rpmQueryFlags qva_flags;    /*!< Bit(s) to control verification. */
  470.     int buildAmount;        /*!< Bit(s) to control operation. */
  471. /*@null@*/
  472.     const char * buildRootOverride; /*!< from --buildroot */
  473. /*@null@*/
  474.     char * targets;        /*!< Target platform(s), comma separated. */
  475. /*@observer@*/
  476.     const char * passPhrase;    /*!< Pass phrase. */
  477. /*@only@*/ /*@null@*/
  478.     const char * cookie;    /*!< NULL for binary, ??? for source, rpm's */
  479.     int force;            /*!< from --force */
  480.     int noBuild;        /*!< from --nobuild */
  481.     int noDeps;            /*!< from --nodeps */
  482.     int noLang;            /*!< from --nolang */
  483.     int shortCircuit;        /*!< from --short-circuit */
  484.     int sign;            /*!< from --sign */
  485.     int useCatalog;        /*!< from --usecatalog */
  486.     char buildMode;        /*!< Build mode (one of "btBC") */
  487.     char buildChar;        /*!< Build stage (one of "abcilps ") */
  488. /*@observer@*/ /*@null@*/
  489.     const char * rootdir;
  490. };
  491.  
  492. /** \ingroup rpmcli
  493.  */
  494. typedef    struct rpmBuildArguments_s *    BTA_t;
  495.  
  496. /** \ingroup rpmcli
  497.  */
  498. /*@unchecked@*/
  499. extern struct rpmBuildArguments_s    rpmBTArgs;
  500.  
  501. /** \ingroup rpmcli
  502.  */
  503. /*@unchecked@*/
  504. extern struct poptOption        rpmBuildPoptTable[];
  505.  
  506. /*@}*/
  507. /* ==================================================================== */
  508. /** \name RPMEIU */
  509. /*@{*/
  510. /* --- install/upgrade/erase modes */
  511.  
  512. /*@unchecked@*/
  513. extern int rpmcliPackagesTotal;
  514. /*@unchecked@*/
  515. extern int rpmcliHashesCurrent;
  516. /*@unchecked@*/
  517. extern int rpmcliHashesTotal;
  518. /*@unchecked@*/
  519. extern int rpmcliProgressCurrent;
  520. /*@unchecked@*/
  521. extern int rpmcliProgressTotal;
  522.  
  523. /** \ingroup rpmcli
  524.  * The rpm CLI generic transaction callback handler.
  525.  * @todo Remove headerSprintf() from the progress callback.
  526.  * @deprecated Transaction callback arguments need to change, so don't rely on
  527.  * this routine in the rpmcli API.
  528.  *
  529.  * @param arg        per-callback private data (e.g. an rpm header)
  530.  * @param what        callback identifier
  531.  * @param amount    per-callback progress info
  532.  * @param total        per-callback progress info
  533.  * @param key        opaque header key (e.g. file name or PyObject)
  534.  * @param data        private data (e.g. rpmInstallInterfaceFlags)
  535.  * @return        per-callback data (e.g. an opened FD_t)
  536.  */
  537. /*@null@*/
  538. void * rpmShowProgress(/*@null@*/ const void * arg,
  539.         const rpmCallbackType what,
  540.         const unsigned long amount,
  541.         const unsigned long total,
  542.         /*@null@*/ fnpyKey key,
  543.         /*@null@*/ void * data)
  544.     /*@globals rpmcliHashesCurrent,
  545.         rpmcliProgressCurrent, rpmcliProgressTotal,
  546.         h_errno, fileSystem, internalState @*/
  547.     /*@modifies rpmcliHashesCurrent,
  548.         rpmcliProgressCurrent, rpmcliProgressTotal,
  549.         fileSystem, internalState @*/;
  550.  
  551. /** \ingroup rpmcli
  552.  * Install source rpm package.
  553.  * @param ts        transaction set
  554.  * @param arg        source rpm file name
  555.  * @retval *specFilePtr    (installed) spec file name
  556.  * @retval *cookie
  557.  * @return        0 on success
  558.  */
  559. int rpmInstallSource(rpmts ts, const char * arg,
  560.         /*@null@*/ /*@out@*/ const char ** specFilePtr,
  561.         /*@null@*/ /*@out@*/ const char ** cookie)
  562.     /*@globals rpmGlobalMacroContext, h_errno,
  563.         fileSystem, internalState@*/
  564.     /*@modifies ts, *specFilePtr, *cookie, rpmGlobalMacroContext,
  565.         fileSystem, internalState @*/;
  566.  
  567. /** \ingroup rpmcli
  568.  * Describe database command line requests.
  569.  */
  570. struct rpmInstallArguments_s {
  571.     rpmtransFlags transFlags;
  572.     rpmprobFilterFlags probFilter;
  573.     rpmInstallInterfaceFlags installInterfaceFlags;
  574.     rpmEraseInterfaceFlags eraseInterfaceFlags;
  575.     rpmQueryFlags qva_flags;    /*!< from --nodigest/--nosignature */
  576.     uint_32 rbtid;        /*!< from --rollback */
  577.     int numRelocations;
  578.     int noDeps;
  579.     int incldocs;
  580. /*@owned@*/ /*@null@*/
  581.     rpmRelocation * relocations;
  582. /*@null@*/
  583.     const char * prefix;
  584. /*@observer@*/ /*@null@*/
  585.     const char * rootdir;
  586. };
  587.  
  588. /** \ingroup rpmcli
  589.  * Install/upgrade/freshen binary rpm package.
  590.  * @param ts        transaction set
  591.  * @param ia        mode flags and parameters
  592.  * @param fileArgv    array of package file names (NULL terminated)
  593.  * @return        0 on success
  594.  */
  595. int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia,
  596.         /*@null@*/ const char ** fileArgv)
  597.     /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
  598.         fileSystem, internalState@*/
  599.     /*@modifies ts, ia, rpmcliPackagesTotal, rpmGlobalMacroContext,
  600.         fileSystem, internalState @*/;
  601.  
  602. /** \ingroup rpmcli
  603.  * Erase binary rpm package.
  604.  * @param ts        transaction set
  605.  * @param ia        control args/bits
  606.  * @param argv        array of package file names (NULL terminated)
  607.  * @return        0 on success
  608.  */
  609. int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
  610.         /*@null@*/ const char ** argv)
  611.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  612.     /*@modifies ts, ia, rpmGlobalMacroContext,
  613.         fileSystem, internalState @*/;
  614.  
  615. /**
  616.  * A rollback transaction id element.
  617.  */
  618. /*@-fielduse@*/
  619. typedef /*@abstract@*/ struct IDT_s {
  620.     unsigned int instance;    /*!< installed package transaction id. */
  621. /*@owned@*/ /*@null@*/
  622.     const char * key;        /*! removed package file name. */
  623.     Header h;            /*!< removed package header. */
  624.     union {
  625.     uint_32 u32;        /*!< install/remove transaction id */
  626.     } val;
  627. } * IDT;
  628. /*@=fielduse@*/
  629.  
  630. /**
  631.  * A rollback transaction id index.
  632.  */
  633. typedef /*@abstract@*/ struct IDTindex_s {
  634.     int delta;            /*!< no. elements to realloc as a chunk. */
  635.     int size;            /*!< size of id index element. */
  636.     int alloced;        /*!< current number of elements allocated. */
  637.     int nidt;            /*!< current number of elements initialized. */
  638. /*@only@*/ /*@null@*/
  639.     IDT idt;            /*!< id index elements. */
  640. } * IDTX;
  641.  
  642. /**
  643.  * Destroy id index.
  644.  * @param idtx        id index
  645.  * @return        NULL always
  646.  */
  647. /*@null@*/
  648. IDTX IDTXfree(/*@only@*/ /*@null@*/ IDTX idtx)
  649.     /*@modifies idtx @*/;
  650.  
  651. /**
  652.  * Create id index.
  653.  * @return        new id index
  654.  */
  655. /*@only@*/
  656. IDTX IDTXnew(void)
  657.     /*@*/;
  658.  
  659. /**
  660.  * Insure that index has room for "need" elements.
  661.  * @param idtx        id index
  662.  * @param need        additional no. of elements needed
  663.  * @return         id index (with room for "need" elements)
  664.  */
  665. /*@only@*/ /*@null@*/
  666. IDTX IDTXgrow(/*@only@*/ /*@null@*/ IDTX idtx, int need)
  667.     /*@modifies idtx @*/;
  668.  
  669. /**
  670.  * Sort tag (instance,value) pairs.
  671.  * @param idtx        id index
  672.  * @return         id index
  673.  */
  674. /*@only@*/ /*@null@*/
  675. IDTX IDTXsort(/*@only@*/ /*@null@*/ IDTX idtx)
  676.     /*@modifies idtx @*/;
  677.  
  678. /**
  679.  * Load tag (instance,value) pairs from rpm databse, and return sorted id index.
  680.  * @param ts        transaction set
  681.  * @param tag        rpm tag
  682.  * @return         id index
  683.  */
  684. /*@only@*/ /*@null@*/
  685. IDTX IDTXload(rpmts ts, rpmTag tag)
  686.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  687.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState  @*/;
  688.  
  689. /**
  690.  * Load tag (instance,value) pairs from packages, and return sorted id index.
  691.  * @param ts        transaction set
  692.  * @param globstr    glob expression
  693.  * @param tag        rpm tag
  694.  * @return         id index
  695.  */
  696. /*@only@*/ /*@null@*/
  697. IDTX IDTXglob(rpmts ts, const char * globstr, rpmTag tag)
  698.     /*@globals rpmGlobalMacroContext, h_errno, fileSystem, internalState @*/
  699.     /*@modifies ts, rpmGlobalMacroContext, fileSystem, internalState @*/;
  700.  
  701. /** \ingroup rpmcli
  702.  * Rollback transactions, erasing new, reinstalling old, package(s).
  703.  * @param ts        transaction set
  704.  * @param ia        mode flags and parameters
  705.  * @param argv        array of arguments (NULL terminated)
  706.  * @return        0 on success
  707.  */
  708. int rpmRollback(rpmts ts, struct rpmInstallArguments_s * ia,
  709.         /*@null@*/ const char ** argv)
  710.     /*@globals rpmcliPackagesTotal, rpmGlobalMacroContext, h_errno,
  711.         fileSystem, internalState @*/
  712.     /*@modifies ts, ia, rpmcliPackagesTotal, rpmGlobalMacroContext,
  713.         fileSystem, internalState @*/;
  714.  
  715. /** \ingroup rpmcli
  716.  */
  717. /*@unchecked@*/
  718. extern struct rpmInstallArguments_s rpmIArgs;
  719.  
  720. /** \ingroup rpmcli
  721.  */
  722. /*@unchecked@*/
  723. extern struct poptOption rpmInstallPoptTable[];
  724.  
  725. /*@}*/
  726. /* ==================================================================== */
  727. /** \name RPMDB */
  728. /*@{*/
  729. /* --- database modes */
  730.  
  731. /** \ingroup rpmcli
  732.  * Describe database command line requests.
  733.  */
  734. struct rpmDatabaseArguments_s {
  735.     int init;            /*!< from --initdb */
  736.     int rebuild;        /*!< from --rebuilddb */
  737.     int verify;            /*!< from --verifydb */
  738. };
  739.  
  740. /** \ingroup rpmcli
  741.  */
  742. /*@unchecked@*/
  743. extern struct rpmDatabaseArguments_s rpmDBArgs;
  744.  
  745. /** \ingroup rpmcli
  746.  */
  747. /*@unchecked@*/
  748. extern struct poptOption rpmDatabasePoptTable[];
  749.  
  750. /*@}*/
  751. /* ==================================================================== */
  752. /** \name RPMK */
  753. /*@{*/
  754.  
  755. /** \ingroup rpmcli
  756.  * Import public key packet(s).
  757.  * @todo Implicit --update policy for gpg-pubkey headers.
  758.  * @param ts        transaction set
  759.  * @param pkt        pgp pubkey packet(s)
  760.  * @param pktlen    pgp pubkey length
  761.  * @return        RPMRC_OK/RPMRC_FAIL
  762.  */
  763. rpmRC rpmcliImportPubkey(const rpmts ts,
  764.         const unsigned char * pkt, ssize_t pktlen)
  765.     /*@globals RPMVERSION, rpmGlobalMacroContext, h_errno,
  766.         fileSystem, internalState @*/
  767.     /*@modifies ts, rpmGlobalMacroContext,
  768.         fileSystem, internalState @*/;
  769.  
  770. /** \ingroup rpmcli
  771.  * Bit(s) to control rpmReSign() operation.
  772.  */
  773. /*@-typeuse@*/
  774. typedef enum rpmSignFlags_e {
  775.     RPMSIGN_NONE        = 0,
  776.     RPMSIGN_CHK_SIGNATURE    = 'K',    /*!< from --checksig */
  777.     RPMSIGN_NEW_SIGNATURE    = 'R',    /*!< from --resign */
  778.     RPMSIGN_ADD_SIGNATURE    = 'A',    /*!< from --addsign */
  779.     RPMSIGN_DEL_SIGNATURE    = 'D',    /*!< from --delsign */
  780.     RPMSIGN_IMPORT_PUBKEY    = 'I',    /*!< from --import */
  781. } rpmSignFlags;
  782. /*@=typeuse@*/
  783.  
  784. /** \ingroup rpmcli
  785.  */
  786. /*@unchecked@*/
  787. extern struct poptOption rpmSignPoptTable[];
  788.  
  789. /** \ingroup rpmcli
  790.  * Create/Modify/Check elements from signature header.
  791.  * @param ts        transaction set
  792.  * @param qva        mode flags and parameters
  793.  * @param argv        array of arguments (NULL terminated)
  794.  * @return        0 on success
  795.  */
  796. int rpmcliSign(rpmts ts, QVA_t qva, /*@null@*/ const char ** argv)
  797.     /*@globals RPMVERSION, rpmGlobalMacroContext, h_errno,
  798.         fileSystem, internalState @*/
  799.     /*@modifies ts, qva, rpmGlobalMacroContext,
  800.         fileSystem, internalState @*/;
  801.  
  802. /*@}*/
  803.  
  804. #ifdef __cplusplus
  805. }
  806. #endif
  807.  
  808. #endif    /* H_RPMCLI */
  809.